---
layout: "default"
title: "FloatingPointType"
description: "Swift documentation for 'FloatingPointType': A set of common requirements for Swift&#39;s floating point types."
keywords: "FloatingPointType,protocol,swift,documentation,<,<=,==,>,>=,_fromBitPattern,_toBitPattern,advancedBy,distanceTo,NaN,floatingPointClass,infinity,isFinite,isInfinite,isNaN,isNormal,isSignMinus,isSignaling,isSubnormal,isZero,quietNaN,_BitsType,Stride"
root: "/v1.2"
---

<div class="intro-declaration"><code class="language-swift">protocol FloatingPointType</code></div>

<div class="discussion comment">
    <p>A set of common requirements for Swift&#39;s floating point types.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">Comparable, Equatable, Strideable, _Comparable, _Strideable</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">_BitsType</code>
</div>
<div class="declaration inherited">
<code class="language-swift">Stride : SignedNumberType</code>
<div class="comment">
    <p>A type that can represent the distance between two values of <code>Self</code></p>
</div>
</div>
</td>
</tr>


<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-int">init(<wbr>_: Int)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-int"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: Int)</code>

    </div></div>
</div>
<div class="declaration" id="init_-int8">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-int8">init(<wbr>_: Int8)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-int8"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: Int8)</code>

    </div></div>
</div>
<div class="declaration" id="init_-int16">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-int16">init(<wbr>_: Int16)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-int16"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: Int16)</code>

    </div></div>
</div>
<div class="declaration" id="init_-int32">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-int32">init(<wbr>_: Int32)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-int32"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: Int32)</code>

    </div></div>
</div>
<div class="declaration" id="init_-int64">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-int64">init(<wbr>_: Int64)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-int64"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: Int64)</code>

    </div></div>
</div>
<div class="declaration" id="init_-uint">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-uint">init(<wbr>_: UInt)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-uint"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: UInt)</code>

    </div></div>
</div>
<div class="declaration" id="init_-uint8">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-uint8">init(<wbr>_: UInt8)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-uint8"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: UInt8)</code>

    </div></div>
</div>
<div class="declaration" id="init_-uint16">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-uint16">init(<wbr>_: UInt16)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-uint16"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: UInt16)</code>

    </div></div>
</div>
<div class="declaration" id="init_-uint32">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-uint32">init(<wbr>_: UInt32)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-uint32"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: UInt32)</code>

    </div></div>
</div>
<div class="declaration" id="init_-uint64">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-uint64">init(<wbr>_: UInt64)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init_-uint64"><div class="p">
    <p>Create an instance initialized to <code>value</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ value: UInt64)</code>

    </div></div>
</div>

<h3>Static Variables</h3>
<div class="declaration" id="static-var-nan_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-static-var-nan_-self">static var NaN: Self</a> <span class="required">Required</span><div class="comment collapse" id="comment-static-var-nan_-self"><div class="p">
    <p>A quiet NaN.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static var NaN: Self { get }</code>

    </div></div>
</div>
<div class="declaration" id="static-var-infinity_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-static-var-infinity_-self">static var infinity: Self</a> <span class="required">Required</span><div class="comment collapse" id="comment-static-var-infinity_-self"><div class="p">
    <p>The positive infinity.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static var infinity: Self { get }</code>

    </div></div>
</div>
<div class="declaration" id="static-var-quietnan_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-static-var-quietnan_-self">static var quietNaN: Self</a> <span class="required">Required</span><div class="comment collapse" id="comment-static-var-quietnan_-self"><div class="p">
    <p>A quiet NaN.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">static var quietNaN: Self { get }</code>

    </div></div>
</div>

<h3>Instance Variables</h3>
<div class="declaration" id="var-floatingpointclass_-floatingpointclassification">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-floatingpointclass_-floatingpointclassification">var floatingPointClass: FloatingPointClassification</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-floatingpointclass_-floatingpointclassification"><div class="p">
    <p>@{
IEEE 754-2008 Non-computational operations.
The IEEE 754 &quot;class&quot; of this type.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var floatingPointClass: FloatingPointClassification { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-isfinite_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-isfinite_-bool">var isFinite: Bool</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-isfinite_-bool"><div class="p">
    <p><code>true</code> iff <code>self</code> is zero, subnormal, or normal (not infinity
or NaN).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isFinite: Bool { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-isinfinite_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-isinfinite_-bool">var isInfinite: Bool</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-isinfinite_-bool"><div class="p">
    <p><code>true</code> iff <code>self</code> is infinity.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isInfinite: Bool { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-isnan_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-isnan_-bool">var isNaN: Bool</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-isnan_-bool"><div class="p">
    <p><code>true</code> iff <code>self</code> is NaN.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isNaN: Bool { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-isnormal_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-isnormal_-bool">var isNormal: Bool</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-isnormal_-bool"><div class="p">
    <p><code>true</code> iff <code>self</code> is normal (not zero, subnormal, infinity, or
NaN).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isNormal: Bool { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-issignminus_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-issignminus_-bool">var isSignMinus: Bool</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-issignminus_-bool"><div class="p">
    <p><code>true</code> iff <code>self</code> is negative</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isSignMinus: Bool { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-issignaling_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-issignaling_-bool">var isSignaling: Bool</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-issignaling_-bool"><div class="p">
    <p><code>true</code> iff <code>self</code> is a signaling NaN.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isSignaling: Bool { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-issubnormal_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-issubnormal_-bool">var isSubnormal: Bool</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-issubnormal_-bool"><div class="p">
    <p><code>true</code> iff <code>self</code> is subnormal.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isSubnormal: Bool { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-iszero_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-iszero_-bool">var isZero: Bool</a> <span class="required">Required</span><div class="comment collapse" id="comment-var-iszero_-bool"><div class="p">
    <p><code>true</code> iff <code>self</code> is +0.0 or -0.0.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isZero: Bool { get }</code>

    </div></div>
</div>


<h3>Static Methods</h3>
<div class="declaration" id="func--frombitpattern_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func--frombitpattern_">static func _fromBitPattern(<wbr>_:)</a>
     <span class="required">Required</span>    
<div class="comment collapse" id="comment-func--frombitpattern_"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">static func _fromBitPattern(bits: _BitsType) -&gt; Self</code>
    
    
</div></div>
</div>

<h3>Instance Methods</h3>
<div class="declaration inherited" id="func-lt_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-lt_rhs_">func &lt;(<wbr>_:<wbr>rhs:)</a>
     <span class="required">Required</span>    
<div class="comment collapse" id="comment-func-lt_rhs_"><div class="p">
    <p>A <a href="http://en.wikipedia.org/wiki/Total_order#Strict_total_order">strict total order</a>
over instances of <code>Self</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &lt;(lhs: Self, rhs: Self) -&gt; Bool</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/_Comparable/"><code>_Comparable</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-lteq_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-lteq_rhs_">func &lt;=(<wbr>_:<wbr>rhs:)</a>
        
<div class="comment collapse" id="comment-func-lteq_rhs_"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func &lt;=(lhs: Self, rhs: Self) -&gt; Bool</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Comparable/"><code>Comparable</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-eqeq_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-eqeq_rhs_">func ==(<wbr>_:<wbr>rhs:)</a>
     <span class="required">Required</span>    
<div class="comment collapse" id="comment-func-eqeq_rhs_"><div class="p">
    <p>Return true if <code>lhs</code> is equal to <code>rhs</code>.</p>

<p><strong>Equality implies substitutability</strong>.  When <code>x == y</code>, <code>x</code> and
<code>y</code> are interchangeable in any code that only depends on their
values.</p>

<p>Class instance identity as distinguished by triple-equals <code>===</code>
is notably not part of an instance&#39;s value.  Exposing other
non-value aspects of <code>Equatable</code> types is discouraged, and any
that <em>are</em> exposed should be explicitly pointed out in
documentation.</p>

<p><strong>Equality is an equivalence relation</strong></p>

<ul><li><code>x == x</code> is <code>true</code></li><li><code>x == y</code> implies <code>y == x</code></li><li><code>x == y</code> and <code>y == z</code> implies <code>x == z</code></li></ul>

<p><strong>Inequality is the inverse of equality</strong>, i.e. <code>!(x == y)</code> iff
<code>x != y</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func ==(lhs: Self, rhs: Self) -&gt; Bool</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Equatable/"><code>Equatable</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-gt_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-gt_rhs_">func &gt;(<wbr>_:<wbr>rhs:)</a>
        
<div class="comment collapse" id="comment-func-gt_rhs_"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func &gt;(lhs: Self, rhs: Self) -&gt; Bool</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Comparable/"><code>Comparable</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-gteq_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-gteq_rhs_">func &gt;=(<wbr>_:<wbr>rhs:)</a>
        
<div class="comment collapse" id="comment-func-gteq_rhs_"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func &gt;=(lhs: Self, rhs: Self) -&gt; Bool</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Comparable/"><code>Comparable</code></a>    
</div></div>
</div>
<div class="declaration" id="func--tobitpattern">
<a class="toggle-link" data-toggle="collapse" href="#comment-func--tobitpattern">func _toBitPattern()</a>
     <span class="required">Required</span>    
<div class="comment collapse" id="comment-func--tobitpattern"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func _toBitPattern() -&gt; _BitsType</code>
    
    
</div></div>
</div>
<div class="declaration inherited" id="func-advancedby_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-advancedby_">func advancedBy(<wbr>_:)</a>
     <span class="required">Required</span>    
<div class="comment collapse" id="comment-func-advancedby_"><div class="p">
    <p>Returns a <code>Self</code> <code>x</code> such that <code>self.distanceTo(x)</code> approximates
<code>n</code>.</p>

<p>Complexity: O(1).</p>

<p>See also: <code>RandomAccessIndexType</code>&#39;s <code>advancedBy</code>, which
provides a stronger semantic guarantee.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func advancedBy(n: Stride) -&gt; Self</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/_Strideable/"><code>_Strideable</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-distanceto_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-distanceto_">func distanceTo(<wbr>_:)</a>
     <span class="required">Required</span>    
<div class="comment collapse" id="comment-func-distanceto_"><div class="p">
    <p>Returns a stride <code>x</code> such that <code>self.advancedBy(x)</code> approximates
<code>other</code>.</p>

<p>Complexity: O(1).</p>

<p>See also: <code>RandomAccessIndexType</code>&#39;s <code>distanceTo</code>, which provides a
stronger semantic guarantee.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func distanceTo(other: Self) -&gt; Stride</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/_Strideable/"><code>_Strideable</code></a>    
</div></div>
</div>


